
/**
 *
 */

import java.io.*;
import java.util.*;
import javax.comm.*;

public class ProjectGPSse {
  static Enumeration portList;
  static CommPortIdentifier portId;

  static SerialPort serialPort;
  static OutputStream serialOut;
  static InputStream serialIn;

  private static final String PROGRAM_NAME = "ProjectGPSse";

  private static final String PORT_NAME = "COM15";
  private static final int PORT_TIMEOUT = 2000;

  private static final int PORT_BAUD = 4800;
  private static final int PORT_DATABITS = SerialPort.DATABITS_8;
  private static final int PORT_STOPBITS = SerialPort.STOPBITS_1;
  private static final int PORT_PARITY = SerialPort.PARITY_NONE;


  public static void main(String[] args) {

  //  createSerialPort();


    NTrip ntrip = new NTrip();
    ntrip.getSourceTable();
    //ntrip.streamData(serialOut);

   // NMEAReader  nmeaReader = new NMEAReader(serialIn);
    //nmeaReader.start();

  //  SandBox sb = new SandBox();
  //  System.out.println(sb.formatLat(NMEA.lat));

  // Calendar rightNow = Calendar.getInstance();
  // System.out.println(rightNow.getTime());




     /* for(int i = 0; i<360; i++){
        System.out.println(10000*oMathFP.sin(oMathFP.deg2rad(i)));
      }*/

 //    System.out.println(SandBox.googleMap());
  }

  /**
   * Creates and intialises serial port with name PORT_NAME
   * Creates I/O streams for this serial port
   *
   */
  private static void createSerialPort() {

    // Get list of all ports
    portList = CommPortIdentifier.getPortIdentifiers();

    // Recurse to find port with PORT_NAME
    while (portList.hasMoreElements()) {
      portId = (CommPortIdentifier) portList.nextElement();

      if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
        if (portId.getName().equals(PORT_NAME)) {

          try {
            serialPort = (SerialPort) portId.open(PROGRAM_NAME, PORT_TIMEOUT);
          }
          catch (PortInUseException e) {}
          try {

            // Get serial port I/O streams
            serialOut = serialPort.getOutputStream();
            serialIn = serialPort.getInputStream();
          }
          catch (IOException e) {}
          try {
            serialPort.setSerialPortParams(PORT_BAUD,
                                           PORT_DATABITS,
                                           PORT_STOPBITS,
                                           PORT_PARITY);
          }
          catch (UnsupportedCommOperationException e) {}
        }
      }
    }
  }
}
